<?php
class Zend_View_Helper_Analitycs extends Zend_View_Helper_Abstract
{
    public function analitycs()
    {
        return $this;
    }
    
    public function google()
    {
        if(  User::getRole() == "user"   ) return;
        
        $config = Zend_Registry::get('config');
        if (!isset($config->analitycs) ) return;
        
        if (isset($config->analitycs->google) && $config->analitycs->google->enabled)
        {
            echo "<script type=\"text/javascript\">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', '" . $config->analitycs->google->id . "']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
</script>" ;
        }
        return $this; 
//        ;
    } 
    
    
    public function mailru()
    {
        if(  User::getRole() == "user"   ) return;
        
        
        $config = Zend_Registry::get('config');
        if (!isset($config->analitycs) ) return;
        
        if (isset($config->analitycs->mail_ru) && $config->analitycs->mail_ru->enabled)
        {
            
            $id = $config->analitycs->mail_ru->id;
        echo '<!--Rating@Mail.ru counter-->
<script language="javascript"><!--
d=document;var a=\'\';a+=\';r=\'+escape(d.referrer);js=10;//--></script>
<script language="javascript1.1"><!--
a+=\';j=\'+navigator.javaEnabled();js=11;//--></script>
<script language="javascript1.2"><!--
s=screen;a+=\';s=\'+s.width+\'*\'+s.height;
a+=\';d=\'+(s.colorDepth?s.colorDepth:s.pixelDepth);js=12;//--></script>
<script language="javascript1.3"><!--
js=13;//--></script><script language="javascript" type="text/javascript"><!--
d.write(\'<a href="http://top.mail.ru/jump?from=' . $id . '" target="_top">\'+
\'<img src="http://dc.cf.bd.a1.top.mail.ru/counter?id=' . $id . ';t=83;js=\'+js+
a+\';rand=\'+Math.random()+\'" alt="Рейтинг@Mail.ru" border="0" \'+
\'height="18" width="88"><\/a>\');if(11<js)d.write(\'<\'+\'!-- \');//--></script>
<noscript><a target="_top" href="http://top.mail.ru/jump?from=' . $id . '">
<img src="http://dc.cf.bd.a1.top.mail.ru/counter?js=na;id=' . $id . ';t=83" 
height="18" width="88" border="0" alt="Рейтинг@Mail.ru"></a></noscript>
<script language="javascript" type="text/javascript"><!--
if(11<js)d.write(\'--\'+\'>\');//--></script>
<!--// Rating@Mail.ru counter-->';
        }

        return $this;
    } 
}
